/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  

  checkConfig(config);
  @endpoint = getEndpoint('dycdpapi', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model QueryCdpOfferRequest {
  ownerId?: long(name='OwnerId'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
  vendor?: string(name='Vendor'),
  channelType?: string(name='ChannelType'),
  province?: string(name='Province'),
}

model QueryCdpOfferResponseBody = {
  flowOffers?: {
    flowOffer?: [ 
    {
      right?: string(name='Right'),
      useEff?: string(name='UseEff'),
      channelType?: string(name='ChannelType'),
      useLimit?: string(name='UseLimit'),
      useScene?: string(name='UseScene'),
      vendor?: string(name='Vendor'),
      grade?: string(name='Grade'),
      offerId?: long(name='OfferId'),
      price?: long(name='Price'),
      flowType?: string(name='FlowType'),
      discount?: string(name='Discount'),
      province?: string(name='Province'),
    }
  ](name='FlowOffer')
  }(name='FlowOffers'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  code?: string(name='Code'),
}

model QueryCdpOfferResponse = {
  headers: map[string]string(name='headers'),
  body: QueryCdpOfferResponseBody(name='body'),
}

async function queryCdpOfferWithOptions(request: QueryCdpOfferRequest, runtime: Util.RuntimeOptions): QueryCdpOfferResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('QueryCdpOffer', '2018-06-10', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function queryCdpOffer(request: QueryCdpOfferRequest): QueryCdpOfferResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryCdpOfferWithOptions(request, runtime);
}

model QueryCdpOfferByIdRequest {
  ownerId?: long(name='OwnerId'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
  offerId?: long(name='OfferId'),
}

model QueryCdpOfferByIdResponseBody = {
  flowOffers?: {
    flowOffer?: [ 
    {
      right?: string(name='Right'),
      useEff?: string(name='UseEff'),
      channelType?: string(name='ChannelType'),
      useLimit?: string(name='UseLimit'),
      useScene?: string(name='UseScene'),
      vendor?: string(name='Vendor'),
      grade?: string(name='Grade'),
      offerId?: long(name='OfferId'),
      price?: long(name='Price'),
      flowType?: string(name='FlowType'),
      discount?: string(name='Discount'),
      province?: string(name='Province'),
    }
  ](name='FlowOffer')
  }(name='FlowOffers'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  code?: string(name='Code'),
}

model QueryCdpOfferByIdResponse = {
  headers: map[string]string(name='headers'),
  body: QueryCdpOfferByIdResponseBody(name='body'),
}

async function queryCdpOfferByIdWithOptions(request: QueryCdpOfferByIdRequest, runtime: Util.RuntimeOptions): QueryCdpOfferByIdResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('QueryCdpOfferById', '2018-06-10', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function queryCdpOfferById(request: QueryCdpOfferByIdRequest): QueryCdpOfferByIdResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryCdpOfferByIdWithOptions(request, runtime);
}

model QueryCdpOrderRequest {
  ownerId?: long(name='OwnerId'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
  outOrderId?: string(name='OutOrderId'),
}

model QueryCdpOrderResponseBody = {
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  data?: {
    extendParam?: string(name='ExtendParam'),
    resultCode?: string(name='ResultCode'),
    resultMsg?: string(name='ResultMsg'),
  }(name='Data'),
  code?: string(name='Code'),
}

model QueryCdpOrderResponse = {
  headers: map[string]string(name='headers'),
  body: QueryCdpOrderResponseBody(name='body'),
}

async function queryCdpOrderWithOptions(request: QueryCdpOrderRequest, runtime: Util.RuntimeOptions): QueryCdpOrderResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('QueryCdpOrder', '2018-06-10', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function queryCdpOrder(request: QueryCdpOrderRequest): QueryCdpOrderResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryCdpOrderWithOptions(request, runtime);
}

